package com.lyhui.nursingproject5020.controller.restful;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyhui.nursingproject5020.pojo.Project;
import com.lyhui.nursingproject5020.service.ProjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Project表的控制层
 *
 * @author lyhui
 * @create-time 2020-02-19 16:09:05
 */
@RestController
@RequestMapping("/project")
public class ProjectRestController {
    private static final Logger logger = LoggerFactory.getLogger(ProjectRestController.class);
    
    @Resource
    private ProjectService projectService;

    /**
     * 查询所有护理项目
     * @param page
     * @return
     */
    @RequestMapping("/list")
    private PageInfo<Project> getProjectList(@RequestParam("page") int page) {
        PageHelper.startPage(page, 5);
        List<Project> projectList = projectService.queryAllProject();
        PageInfo<Project> pageInfo = new PageInfo<>(projectList);
        return pageInfo;
    }

    @RequestMapping("/getListByParam")
    private PageInfo<Project> getProjectListByParam(@RequestParam("page") int page,Project project) {
        PageHelper.startPage(page, 5);
        List<Project> projectList = projectService.queryProjectListByParam(project);
        PageInfo<Project> pageInfo = new PageInfo<>(projectList);
        return pageInfo;
    }


}